__author__ = 'Brandon Corfman'

class Player(object):
    def __init__(self, name, agent, dwarf, parent):
        self.name = name
        self.agent = agent
        self.dwarf = dwarf
        self.parent = parent
        self.passed = False
        self.nuggets = 0

    def __eq__(self, other):
        return self.name == other.name

    def __ne__(self, other):
        return self.name != other.name

    def __hash__(self):
        return hash(self.name)

    def __str__(self):
        return self.name

    def display_name(self):
        print("{0} -----".format(self.name))

    def move(self, board, others):
        """
        Use a card, check for end of round, then draw a card.
        Returns True if end of round; False otherwise.
        """
        action = self.agent.play_card(board, others)
        self.passed = action == 'd' and not self.parent.draw_pile

    # method chaining to Dwarf
    def identify_player_type(self):
        return self.dwarf.identify_player_type()

    # method chaining to Agent
    def subscribe(self, subscriber):
        self.agent.subscribe(subscriber)

    def unsubscribe(self, subscriber):
        self.agent.unsubscribe(subscriber)

    def notify(self, msg):
        self.agent.notify(msg)

    def receive(self, msg):
        self.agent.receive(msg)

    def get_states(self):
        return self.agent.get_states()

    def validate(self, row, col, card, board):
        return self.agent.validate(row, col, card, board)

    def play_card(self, board, others):
        return self.agent.play_card(board, others)

    def get_card_choice(self):
        return self.agent.get_card_choice()

    def add_card_to_hand(self, card):
        return self.agent.add_card_to_hand(card)

    def display_hand(self):
        return self.agent.display_hand()
    
    def reveal_goal(self, board, pos):
        return self.agent.reveal_goal(board, pos)
    
    def add_state(self, state):
        self.agent.add_state(state)

    def get_states(self):
        return self.agent.get_states()

    def remove_state(self, state):
        return self.agent.remove_state(state)

    def display_repair_one_precond_failure(self, state):
        return self.agent.display_repair_one_precond_failure(state)

    def display_repair_any_precond_failure(self, state1, state2):
        return self.agent.display_repair_any_precond_failure(state1, state2)

    def decide_path_card(self, board, card):
        return self.agent.decide_path_card(board, card)

    def decide_broken_tool(self, board, state, others):
        return self.agent.decide_broken_tool(board, state, others)

    def decide_rockfall(self, board, card):
        return self.agent.decide_rockfall(board, card)

    def decide_repair_any(self, board, card):
        return self.agent.decide_repair_any(board, card)

    def decide_peek(self, board, card):
        return self.agent.decide_peek(board, card)

